package com.allianz.webapps.controllers;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.allianz.frame.utils.ApplicationContextUtil;
import com.allianz.webapps.https.interfaces.type001.BenefitInit;
import com.allianz.webapps.https.interfaces.type001.CoverInit;
import com.allianz.webapps.https.interfaces.type001.pojo.User;
import com.allianz.webapps.https.interfaces.util.HttpsUtil;
import com.allianz.webapps.https.interfaces.util.ObjectUtil;
import com.allianz.webapps.orderspojo.AppBase;
import com.allianz.webapps.orderspojo.CP;
import com.fasterxml.jackson.databind.ObjectMapper;
@Controller
@RequestMapping(value="benefit")
public class BenefitController {
	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private ObjectUtil objectUtil;
	@RequestMapping(value="index")
	public String index(HttpServletRequest request,HttpServletResponse response){
		return "views/page/benefit";
	}
	@RequestMapping(value="initBenefit")
	@ResponseBody
	public String initBenefit(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HashMap<String,Object> map = new HashMap<String,Object>();
		String cp = request.getParameter("jsonParam");
		AppBase obj =objectMapper.readValue(cp,AppBase.class);
		String body=objectUtil.requestParam(obj, "app.getBeneficiaries");
		return body;
		
	}
	@RequestMapping(value="saveBenefit")
	@ResponseBody
	public String saveCover(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HashMap<String,Object> map = new HashMap<String,Object>();
		String cp = request.getParameter("jsonParam");		
		Object obj =objectMapper.readValue(cp,Object.class);
		String body=objectUtil.requestParam(obj, "app.saveBeneficiaries");
		return body;
		
	}
}